/**
 * Copyright &copy; 2018-2018 <a href="#">聚成科技</a> All rights reserved.
 */
package com.jckj.core.service.impl;

import com.jckj.core.annotation.CurrentDataSource;
import com.jckj.core.dao.NotifyFarmViewMapper;
import com.jckj.core.db.DataSourceEnum;
import com.jckj.core.entity.Notify;
import com.jckj.core.entity.NotifyFarmView;
import com.jckj.core.entity.NotifyFarmViewExample;
import com.jckj.core.exception.ServiceException;
import com.jckj.core.service.NotifyFarmViewService;
import com.jckj.core.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


/**
 * @author :liukuan
 * @date :2018-02-07
 */
@Service
@Transactional(readOnly = true,rollbackFor = ServiceException.class)
public class NotifyFarmViewServiceImpl implements NotifyFarmViewService {

   @Autowired
    private NotifyFarmViewMapper notifyFarmViewMapper;

    @Override
    @CurrentDataSource(DataSourceEnum.SLAVE)
    public List<NotifyFarmView> findByNotify(Notify notify) {
        NotifyFarmViewExample example=new NotifyFarmViewExample();
        NotifyFarmViewExample.Criteria criteria = example.createCriteria();
        if(StringUtils.isNotBlank(notify.getId())){
            criteria.andIdEqualTo(notify.getId());
        }
        if(StringUtils.isNotBlank(notify.getType())){
            criteria.andTypeEqualTo(notify.getType());
        }
        return notifyFarmViewMapper.selectByExample(example);
    }
}
